package com.yc.controller;

import com.yc.biz.impl.PromotionServiceImpl;
import com.yc.dto.Result;
import com.yc.entity.Promotion;
import com.yc.mapper.PromotionMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.stereotype.Controller;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author cxw
 * @since 2025-02-13
 */
@Controller
@RequestMapping("//promotion")
public class PromotionController {
    @Autowired
    PromotionMapper promotionMapper;
    @Autowired
    PromotionServiceImpl promotionService;
    @RequestMapping("getNoBegin")
    Promotion getNoBegin(){
        Promotion promotion=promotionMapper.selectNoBegin();
        return promotion;
    }
  @RequestMapping("begin")
    Result begin(int pid){
        promotionService.begin(pid);
        return new Result(1,"大促活动开始了",null);
    }

    @RequestMapping("end")
    Result end(@RequestBody Promotion promotion){
        promotionService.end(promotion);
        return new Result(1,"大促活动结束了",null);
    }

}
